<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('表级映射信息列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>文档id：</label>
                                <input type="text" name="excelId"/>
                            </li>
                            <li>
                                <label>目标表id：</label>
                                <input type="text" name="targetTableId"/>
                            </li>
                            <li>
                                <label>目标表code：</label>
                                <input type="text" name="targetTableCode"/>
                            </li>
                            <li>
                                <label>目标表名称：</label>
                                <input type="text" name="targetTableName"/>
                            </li>
                            <li>
                                <label>源表id：</label>
                                <input type="text" name="sourceTableId"/>
                            </li>
                            <li>
                                <label>源表code：</label>
                                <input type="text" name="sourceTableCode"/>
                            </li>
                            <li>
                                <label>源表名称：</label>
                                <input type="text" name="sourceTableName"/>
                            </li>
                            <li>
                                <label>表主从分类：</label>
                                <select name="mainSubType">
                                    <option value="">所有</option>
                                    <option value="-1">代码生成请选择字典属性</option>
                                </select>
                            </li>
                            <li>
                                <label>处理状态：</label>
                                <select name="parseStatus">
                                    <option value="">所有</option>
                                    <option value="-1">代码生成请选择字典属性</option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="mapping:table:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="mapping:table:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="mapping:table:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="mapping:table:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('mapping:table:edit')}]];
        var removeFlag = [[${@permission.hasPermi('mapping:table:remove')}]];
        var prefix = ctx + "mapping/table";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "表级映射信息",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'tableId',
                    title: '表映射Id',
                    visible: false
                },
                {
                    field: 'excelId',
                    title: '文档id'
                },
                {
                    field: 'excelFilename',
                    title: '文档名称'
                },
                {
                    field: 'targetTableId',
                    title: '目标表id'
                },
                {
                    field: 'targetTableCode',
                    title: '目标表code'
                },
                {
                    field: 'targetTableName',
                    title: '目标表名称'
                },
                {
                    field: 'sourceTableId',
                    title: '源表id'
                },
                {
                    field: 'sourceTableCode',
                    title: '源表code'
                },
                {
                    field: 'sourceTableName',
                    title: '源表名称'
                },
                {
                    field: 'sourceSql',
                    title: '取源数据sql'
                },
                {
                    field: 'bizScenario',
                    title: '业务场景描述'
                },
                {
                    field: 'mainSubType',
                    title: '表主从分类'
                },
                {
                    field: 'mainSubDetail',
                    title: '表主从关系'
                },
                {
                    field: 'parseStatus',
                    title: '处理状态'
                },
                {
                    field: 'errorMsg',
                    title: '错误信息'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.tableId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push("<a class='btn btn-success btn-xs " + editFlag + "' href='javascript:void(0)' onclick='columnInfo(" + row.tableId + ")'><i class='fa fa-edit'></i>字段映射</a>");
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.tableId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        
		/* 字段信息 */
		function columnInfo(tableId) {
		    var url =  'mapping/field/' + tableId;
		    $.modal.openTab("字段映射信息", url);
		}
    </script>
</body>
</html>